import router from '@/router'
import useUserStore from '@/store/modules/user'
import pinia from '@/store'

const user = useUserStore(pinia)

const token = user.userDatas.token

router.beforeEach((to, from, next) => {
  if (token || window.__POWERED_BY_QIANKUN__) {
    next()
  } else {
    if (to.path === '/login') {
      next()
    } else {
      next('/login')
    }
  }
})